/**
 * list  数据  [{ label: "", value: "1" }]
 * value  默认选中  "1"
 * onChange   回调参数 item
 */

import React from "react";
import { Radio } from "antd";

import "./index.less"

const AppRadioGroup = (props) => {
  const options = props.options || [];
  const value = props.value || options[0]?.value;
  const optionType = props.optionType || "button";
  const buttonStyle = props.buttonStyle || "solid";

  const onChange = (e) => {
    const item = options.find((item) => item.value === e.target.value);
    props.onChange && props.onChange(item);
  };
  return (
    <div className="app-radio-group">
      <Radio.Group
        options={options}
        onChange={(value) => onChange(value)}
        value={value}
        optionType={optionType}
        buttonStyle={buttonStyle}
      />
    </div>
  );
};

export default AppRadioGroup;
